package cn.cms.chuangjia.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.cms.chuangjia.domain.Job;
import cn.cms.chuangjia.vo.AjaxResult;
import cn.cms.chuangjia.vo.Page;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.cms.chuangjia.service.IJobService;


/**
 * 工作机会Controller
 * 
 * @author ruoyi
 * @date 2024-01-18
 */
@RestController
@RequestMapping("/cms/job")
public class JobController extends BaseController
{
    @Autowired
    private IJobService jobService;

    /**
     * 查询工作机会列表
     */
   // @PreAuthorize("@ss.hasPermi('job:job:list')")
    @GetMapping("/list")
    public Page<Job> list(Job job)
    {
        startPage();
        List<Job> list = jobService.selectJobList(job);
        return Page.convert(PageInfo.of(list));
    }

    /**
     * 导出工作机会列表
     */
   // @PreAuthorize("@ss.hasPermi('job:job:export')")
   // @Log(title = "工作机会", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Job job)
//    {
//        List<Job> list = jobService.selectJobList(job);
//        ExcelUtil<Job> util = new ExcelUtil<Job>(Job.class);
//        util.exportExcel(response, list, "工作机会数据");
//    }

    /**
     * 获取工作机会详细信息
     */
    //@PreAuthorize("@ss.hasPermi('job:job:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(jobService.selectJobById(id));
    }

    /**
     * 新增工作机会
     */
    //@PreAuthorize("@ss.hasPermi('job:job:add')")
    //@Log(title = "工作机会", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Job job)
    {
        return AjaxResult.toAjax(jobService.insertJob(job));
    }

    /**
     * 修改工作机会
     */
    //@PreAuthorize("@ss.hasPermi('job:job:edit')")
   // @Log(title = "工作机会", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Job job)
    {
        return AjaxResult.toAjax(jobService.updateJob(job));
    }

    /**
     * 删除工作机会
     */
    //@PreAuthorize("@ss.hasPermi('job:job:remove')")
    //@Log(title = "工作机会", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return AjaxResult.toAjax(jobService.deleteJobByIds(ids));
    }
}
